{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 第一题：决策树处理分类任务"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "1.\t使用sklearn.tree.DecisionTreeClassifier完成dota2比赛结果预测问题\n",
    "2.\t计算最大深度为10时，十折交叉验证的精度(accuracy)，查准率(precision)，查全率(recall)，F1值\n",
    "3.\t绘制最大深度从1到10的决策树十折交叉验证精度的变化图"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "dota2results = np.loadtxt('data/dota2Dataset/dota2Train.csv', delimiter=',')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "dota2x = dota2results[:, 1:]\n",
    "dota2y = dota2results[:, 0]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. 导入模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import cross_val_predict\n",
    "from sklearn.metrics import accuracy_score\n",
    "from sklearn.metrics import precision_score\n",
    "from sklearn.metrics import recall_score\n",
    "from sklearn.metrics import f1_score\n",
    "from sklearn.tree import DecisionTreeClassifier"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. 训练与预测\n",
    "计算最大深度为10的决策树，在使用数据dota2x，标记dota2y下，十折交叉验证的精度，查准率，查全率和F1值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "决策树在dota2测试集上的四项指标\n",
      "精度: 0.550523475445224\n",
      "查准率: 0.5565538442035876\n",
      "查全率: 0.7199991800254192\n",
      "f1值: 0.6278130306551077\n"
     ]
    }
   ],
   "source": [
    "model = DecisionTreeClassifier(max_depth = 10) # 参数max_depth决定了决策树的最大深度\n",
    "# YOUR CODE HERE\n",
    "\n",
    "prediction = cross_val_predict(model,dota2x,dota2y,cv = 10)\n",
    " \n",
    "acc1 = accuracy_score(dota2y,prediction)\n",
    "precision1 = precision_score(dota2y,prediction)\n",
    "recall1 = recall_score(dota2y,prediction)\n",
    "f1 = f1_score(dota2y,prediction)\n",
    "\n",
    "print(\"决策树在dota2测试集上的四项指标\")\n",
    "print(\"精度:\",acc1)\n",
    "print(\"查准率:\",precision1)\n",
    "print(\"查全率:\",recall1)\n",
    "print(\"f1值:\",f1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 双击此处填写下面的表格\n",
    "\n",
    "最大深度为10：  \n",
    "\n",
    "精度 | 查准率 | 查全率 | F1\n",
    "- | - | - | -\n",
    "0.550523475445224 | 0.5565538442035876 | 0.7199991800254192 | 0.6278130306551077"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. 改变最大深度，绘制决策树的精度变换图"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "绘制最大深度从1到10，决策树十折交叉验证精度的变化图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'accuracy_score')"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZwAAAEXCAYAAACZNvIiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi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us+oR/34WtNH9X0LyMmf3JzIaG\nn7uH09coZjkNzOyzcB5PAxYz7Dwz+8nMxpvZ02aWHPbfYGYPmdk4M/vSzBqZ2elAOkGLA+PNrHo4\nm2vC8SaZWadEbjOReCjhiBStPcHLzXoAnYBzgIOBvwB/A6YD/cNWmm8D7gmn+xfQ3sxOAZ4DLnf3\nTcUs43ZgVDiPYUArADPrDJwJ9HP3nkAecG44TU1gnLvvB4wEbnf3t4EM4Fx37+num8NxV4TjPRnG\nLRIptaUmUrR57j4JwMymELw10c1sEtAGSANeMLMOgANVANw938wGAxOBp9199E6W0R84NZzuIzNb\nHfY/HOgNjAnaoaQ621v5zQfeCD+/TNAqcnEKho0tWI5IlJRwRIqWHfM5P6Y7n+C4uQv42t1PCV+O\nNyJm/A7ABuJ7plJUY4YGvODuN//G6QsUxJyHjnUpA1SkJvLbpAGLws+DC3qaWRpBUVx/oEH4fKU4\n3xAWlZnZsUC9sP+XwOlm1jgcVt/MWofDkoCCeZ4DjAo/rwdq78H6iCScEo7Ib/MAcK+ZjQaSY/o/\nAvzH3WcCvwfuK0gcRfgH0N/MxgFHETQfj7tPBf4OfGZmE4HPgabhNBuBrmY2FhgI3Bn2fx54qlCl\nAZEyRa8nEClHzGyDu9eKOg6R30J3OCIiUip0hyOSYGZ2EXBdod6j3f2qKOIRiYoSjoiIlAoVqYmI\nSKlQwhERkVKhhCMiIqVCCUdERErF/wO34Qgpduy/mgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# YOUR CODE HERE\n",
    "y = []\n",
    "\n",
    "for i in range(10):\n",
    "    model = DecisionTreeClassifier(max_depth = i + 1)\n",
    "    prediction = cross_val_predict(model,dota2x,dota2y,cv=10)\n",
    "    y.append(prediction)\n",
    "    \n",
    "x = np.linspace(1,10,10)\n",
    "test = [accuracy_score(dota2y, val) for val in y]\n",
    "\n",
    "plt.figure()\n",
    "plt.plot(x,test,'-')\n",
    "plt.title(\"DecisionTree's accuracy_score changes with the max_depth\")\n",
    "plt.xlabel(\"max_depth\")    \n",
    "plt.ylabel(\"accuracy_score\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 5. （选做）通过调整参数，得到一个泛化能力最好的模型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "查看决策树文档，通过调整决策树的参数，得到一个最好的模型  \n",
    "http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html#sklearn.tree.DecisionTreeClassifier  \n",
    "并在下方给出参数的设定与其泛化性能指标"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**（选做仅供参考）**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用的GridSearchCV，它存在的意义就是自动调参，只要把参数输进去，就能给出最优化的结果和参数。\n",
    "但是这个方法适合于小数据集，一旦数据的量级上去了，很难得出结果。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'min_samples_leaf': 2, 'max_depth': 12, 'criterion': 'entropy', 'min_samples_split': 4, 'max_features': 5}\n",
      "优化后的决策树在dota2测试集上的四项指标\n",
      "精度: 0.5372908796546141\n",
      "查准率: 0.5417502330442643\n",
      "查全率: 0.7862941248821287\n",
      "f1值: 0.641507225046829\n"
     ]
    }
   ],
   "source": [
    "# YOUR CODE HERE\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.model_selection import StratifiedKFold\n",
    "modelfit = DecisionTreeClassifier(max_depth = 10)\n",
    "param_grid = {'criterion':['gini','entropy'],'max_depth':[10,11,12],\n",
    "                  'min_samples_leaf':[1,2,3,4,5],'max_features':[1,2,3,4,5],'min_samples_split':[2,3,4,5]}\n",
    "\n",
    "grid = GridSearchCV(modelfit,param_grid,cv = 10)\n",
    "\n",
    "grid.fit(dota2x,dota2y)\n",
    "\n",
    "best = grid.best_params_  #最优分类器\n",
    "print(best)\n",
    "best_decision_tree_classifier = DecisionTreeClassifier(max_depth = best['max_depth'],max_features=best['max_features'],\n",
    "                                                       min_samples_leaf = best['min_samples_leaf'],min_samples_split = best['min_samples_split'])\n",
    "prediction = cross_val_predict(best_decision_tree_classifier,dota2x,dota2y,cv = 10)\n",
    "\n",
    "acc1 = accuracy_score(prediction,dota2y)\n",
    "precision1 = precision_score(dota2y,prediction)\n",
    "recall1 = recall_score(dota2y,prediction)\n",
    "f1 = f1_score(dota2y,prediction)\n",
    "\n",
    "print(\"优化后的决策树在dota2测试集上的四项指标\")\n",
    "print(\"精度:\",acc1)\n",
    "print(\"查准率:\",precision1)\n",
    "print(\"查全率:\",recall1)\n",
    "print(\"f1值:\",f1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###### 双击此处填写参数设置与性能指标的结果\n",
    "\n",
    "参数设置：  min_samples_leaf': 2, 'max_depth': 12, 'criterion': 'entropy', 'min_samples_split': 4, 'max_features': 5\n",
    "\n",
    "\n",
    "性能指标得分：\n",
    "精度: 0.5372908796546141\n",
    "查准率: 0.5417502330442643\n",
    "查全率: 0.7862941248821287\n",
    "f1值: 0.641507225046829"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
